package com.kizuki.algorithm.leetcode;

/**
 * 给你单链表的头节点 head ，请你反转链表，并返回反转后的链表。
 *
 * https://leetcode-cn.com/problems/reverse-linked-list/
 */
public class 反转链表 {

    class Solution {
        public ListNode reverseList(ListNode head) {
            ListNode pre = null, cur = head, next;
            while(cur != null) {
                next = cur.next;
                cur.next = pre;
                pre = cur;
                cur = next;
            }
            return pre;
        }
    }

}
